%%%-----------------------------------
%%% @Module  : pt_26
%%% @Author  : 
%%% @Created : 
%%% @Description: 
%%%-----------------------------------
-module(pt_26).
-export([read/2, write/2]).
-include("common.hrl").
-include("proto_26_recruit.hrl").

%%
%%客户端 -> 服务端 ----------------------------
%%

%% 26000 请求玩家招募数据
read(26000, Bin) ->
    {ClientData, _} = proto_read:unpack(c2s_get_recruit_data, Bin), 
    [_|Data] = erlang:tuple_to_list(ClientData),
    {ok, Data};

%% 26001 绑定玩家
read(26001, Bin) ->
    {ClientData, _} = proto_read:unpack(c2s_recruit_binding_player, Bin),    
    [_|Data] = erlang:tuple_to_list(ClientData),
    {ok, Data};

%% 26002 领取招募奖励
read(26002, Bin) ->
    {ClientData, _} = proto_read:unpack(c2s_get_recruit_award, Bin),    
    [_|Data] = erlang:tuple_to_list(ClientData),
    {ok, Data};


read(_Cmd, _R) ->
    ?ERROR_MSG("~s pt_26 reading cmd_[~p], Data:~p~n",[misc:time_format(game_timer:now()), _Cmd, _R]),
    {error, no_match}.

%%
%%服务端 -> 客户端 ------------------------------------
%%
%% 26000 请求玩家招募数据
write(26000, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_get_recruit_data, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(26000, ServerData)};

%% 26001 绑定玩家
write(26001, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_recruit_binding_player, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(26001, ServerData)};

%% 26002 领取招募奖励
write(26002, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_get_recruit_award, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(26002, ServerData)};

write(Cmd, _R) ->
    ?ERROR_MSG("~s pt_26 writting cmd_[~p], Data:~p~n",[misc:time_format(game_timer:now()), Cmd, _R]),
    {ok, pt:pack(0, <<>>)}.
